package leetcode.tree;

import leetcode.tree.common.TreeNode;

import java.util.ArrayList;
import java.util.List;

/**
 * @author mazouri
 * @create 2021-05-04 10:47
 */
public class _145_postorderTraversal {
    public List<Integer> postorderTraversal(TreeNode root) {
        List<Integer> list = new ArrayList<>();
        postorder(root,list);
        return list;
    }

    private void postorder(TreeNode root, List<Integer> list) {
        if (root == null){
            return;
        }


        postorder(root.left,list);
        postorder(root.right,list);
        list.add(root.val);
    }
}
